<?php
 @include_once("../php/connect.php");
   
  
   $pwd=$_POST["password"];
   
   if(isset($_POST["phone"])){
       $phone=$_POST["phone"];
        $sql="SELECT password from `userinfo` where phone='$phone'";
        $result=mysqli_query($conn,$sql);
        $obj=array();
        if($result){
            $item=mysqli_fetch_assoc($result);
           if($item){
                if($item['password']==$pwd){
                    $obj['status']=true;
                    $obj['msg']="登录成功";
                }else{
                    $obj['status']=false;
                    $obj['msg']="手机号或密码错误";
                }
            }else{
                 $obj['status']=false;
                 $obj['msg']="该用户还没有注册";
            }
        }
        echo json_encode($obj);
    }else if(isset($_POST["email"])){
         $email=$_POST["email"];
       $sql="SELECT password,phone from `userinfo` where email='$email'";
       $result=mysqli_query($conn,$sql);
       $obj=array();
       if($result){
            $item=mysqli_fetch_assoc($result);
           if($item){
                if($item['password']==$pwd){
                $obj['status']=true;
                $obj['phone']=$item['phone'];
                $obj['msg']="登录成功";
                }else{
                $obj['status']=false;
                $obj['msg']="邮箱或密码错误";
                }
           }else{
             $obj['status']=false;
             $obj['msg']="该用户还没有注册";
            }
        }
        echo json_encode($obj);
   }

?>